import java.io.File;
import java.io.IOException;
import java.util.Date;

public class TestFile1 {
    public static void main(String[] args) throws IOException {
        File dir2=new File("D:/Workspaces");
        File fileName2[]=dir2.listFiles();
        File s=null;
        for (int i = 0; i <fileName2.length ; i++) {
            if (fileName2[i].getName().endsWith(".txt")){
                if (s==null)
                    s=fileName2[i];
                    System.out.println(fileName2[i].getName());

            }
        }
        System.out.println("Name:"+s.getName()+"\nParent:"+s.getParent()
        +"\nPath:"+s.getPath()+"\nAbsolutePath?"+s.getAbsolutePath()+
                "\nAbsolute?"+s.isAbsolute()+
                "\nCan read:"+s.canRead()+
                "\nCan write"+s.canWrite()+"\nExist:"+s.exists()+
                "\nLength:"+s.length()+"\nLast Modified:"+
                new Date(s.lastModified()));
        s=new File("D:\\Workspaces\\a3.txt");
        s.createNewFile();
    }
}
